<?php
/**
 * Created by PhpStorm.
 * User: THUNDEROBOT
 * Date: 2021/1/11
 * Time: 15:29
 */

namespace app\admin\model;

use think\Request;
use think\Config;
use think\Model;

class Score extends Model
{
    public function score(){
        //查询
        $map = [];
        $request = Request::instance();
        //判断是否搜索用户名
        if($request->has("snameS","get")){
            $tuameS = $request->get("snameS");
            $map['s_name'] = ["LIKE","%".$tuameS."%"];
        }

        $data = $this->where($map)->order("id asc")->paginate(Config::get("page_count"),false,[
            "query" =>$request->get()
        ]);
        $data = $this->select();
//        echo $this->getLastSql();
        return $data;
    }

    //编辑学生分数
    public function editScore($id){
        $map["id"] = ["IN","$id"];
        $data = $this->where($map)->find();
        return $data;
    }
    //提交编辑学生分数
    public function doEdit($userData){
        $map = [
            "id" => $userData["id"],
        ];
        $data = [
            "s_score" => $userData["s_score"]
        ];
        $data =  $this->where($map)->update($data);
//        echo $this->getLastSql();
        return $data;
    }

}